<?php

namespace easydis\APSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * Acme\UserBundle\Entity\User
 *
 * @ORM\Table(name="users")
 * @ORM\Entity(repositoryClass="easydis\APSBundle\EntityRepository\UserRepository")
 */
class User implements UserInterface, \Serializable
{ 
  
  /**
   * @ORM\Column(name="username", type="string", length=30, unique=true)
   * @ORM\Id
   */
  protected $username;
 
  /**
   * @ORM\Column(name="password", type="string", length=20)
   */
  protected $password;
 
  /**
   * @ORM\Column(name="salt", type="string", length=255)
   */
  protected $salt;
 
 /**
  * @ORM\Column(name="roles", type="array")
  */
  protected $roles;
  
  /**
   * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\Exploitation")
   * @ORM\JoinColumn(nullable=false)
   */
  protected $exploit;

  /**
    * Set exploit
    *
    * @param easydis\APSBundle\Entity\Exploitation $exploit
    */
  public function setExploit(\easydis\APSBundle\Entity\Exploitation $exploit)
  {
          $this->exploit = $exploit;
  }

  /**
   * Get exploit
   *
   * @return easydis\APSBundle\Entity\Exploitation 
   */
  public function getExploit()
  {
      return $this->exploit;
  }
  
  public function __construct()
  {
    $this->roles = array();
  }
 
  public function getUsername()
  {
    return $this->username;
  }
 
  public function setPassword($password)
  {
    $this->password = $password;
    return $this;
  }
 
  public function getPassword()
  {
    return $this->password;
  }
 
  public function setSalt($salt)
  {
    $this->salt = $salt;
    return $this;
  }
 
  public function getSalt()
  {
    return $this->salt;
  }
 
  public function setRoles(array $roles)
  {
    $this->roles = $roles;
    return $this;
  }
 
  public function getRoles()
  {
    return $this->roles;
  }
 
  public function eraseCredentials()
  {
  }
  
  public function serialize()
    {
           return serialize($this->username);
    }

    public function unserialize($data)
    {
           $this->username = unserialize($data);
    }
}
